#include <iostream>
#include <fcntl.h>

void SetNonBlock(int fd)
{
    int flag = ::fcntl(fd, F_GETFL);
    if(flag < 0)
        return;
    fcntl(fd, F_SETFL, flag | O_NONBLOCK);
}